package com.jnxg.smartcommunity.responseutils;

import org.json.JSONArray;
import org.json.JSONObject;

/**
 * Created by Administrator on 2017/2/28 0028.
 */

public class ResponseUtils {
       public static int getCode(String json){
           int code=-1;
           try {
               JSONObject object = new JSONObject(json);
               code =   Integer.valueOf(object.getString("status"));
           }catch (Exception e){
               e.printStackTrace();
           }
           return code;
       }
    public static String getMsg(String json){
        String message="";
        try {
            JSONObject object = new JSONObject(json);
            message =   object.getString("msg");
        }catch (Exception e){
            e.printStackTrace();
        }
        return message;
    }
    public static String getDataStr(String json){
        String dataStr="";
        try {
            JSONObject object = new JSONObject(json);
            dataStr =   object.getString("data");
        }catch (Exception e){
            e.printStackTrace();
        }
        return dataStr;
    }

    public static String getData(String json){
        String data="";
        try {
            JSONObject object = new JSONObject(json);
            JSONArray dataArray =   object.getJSONArray("data");
            data = dataArray.toString();
        }catch (Exception e){
            e.printStackTrace();
        }
        return data;
    }




}
